package com.kl.forum.service;

import com.kl.forum.dao.UserCircleMapper;
import com.kl.forum.entity.UserCircle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service
public class UserCircleService {
    @Autowired
    private UserCircleMapper userCircleMapper;

    public int insertUserCircle(Integer userId,Integer circleId){
        UserCircle userCircle=new UserCircle();
        userCircle.setUserId(userId);
        userCircle.setCircleId(circleId);
        userCircle.setStatus(1);
        userCircle.setCreateTime(new Date());
       return userCircleMapper.insertSelective(userCircle);
    }

    public int updateUserCircle(Integer userId, Integer circleId,Integer status) {
        Map map=new HashMap();
        map.put("userId",userId);
        map.put("circleId",circleId);
        map.put("status",status);
        return userCircleMapper.updateUserCircle(map);
    }
    public UserCircle findOneUserCircle(Integer userId, Integer circleId){
        return  userCircleMapper.findOneCircleUser(circleId,userId);
    }
}
